<template>
	<view>
		<view class="swiper square">
			<swiper class="skeleton-rect" indicator-dots="true"
				:autoplay="true" :circular="circular" :interval="interval" :duration="duration"
				indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff" :current="swiperCur"
				@change="swiperChange" style="height: 400rpx;">
				<block v-for="(item,index) in carousels" :key="index">
					<swiper-item class="" :class="{active:index == swiperCur}">
						<view style="height: 400rpx;" @click="goDetail(item)" class='slide-navigator acea-row row-between-wrapper'>
							<image :src="item.cover" class="slide-image"></image>
						</view>
					</swiper-item>
				</block>
		
			</swiper>
		</view><!-- 轮播图 end -->
		
		<view class="from_to_bg">
			<view class="left">
				<view class="section">
					<view class="dot"></view>
					<view class="city line">
						<view class="city_tip">出发城市</view>
						<view class="city_text">成都市</view>
					</view>
				</view>
				<view class="section">
					<view class="dot"></view>
					<view class="city">
						<view class="city_tip">出发城市</view>
						<view class="city_text">成都市</view>
					</view>
				</view>
			</view>
			<view class="right">
				<image class="change" src="../../../static/images/change_city.png"></image>
			</view>
		</view><!-- from_to_bg -->
		<view class="func">
			<view class="btn" @click="queryTravel">查询行程</view>
			<view class="btn" @click="publishTravel">发布行程</view>
		</view><!-- func end -->
		
		<view class="blocks">
			<view class="block">
				<view class="top">
					<view class="top_title">推荐路线</view>
					<!-- <view class="top_more" @click="gotoMore()">
						<view class="more_text">其他路线</view>
						<image class="more_arrow" src="../../../static/images/arrow.png"></image>
					</view> -->
				</view>
				<!-- <view class="empty" v-if="doing_data.length == 0">
					<view class="empty_bg">
						<image class="empty_class" src="/static/images/empty_img.png"></image>
					</view>
					<view class="desc_bg">
						周围有
						<text class="red" v-if="driver>10000">{{driver/10000}}w+</text>
						<text class="red" v-else>{{driver}}</text>
						司机等您发货
					</view>
				</view> -->
				<view class="items">
					<view class="item" v-for="item in data">
						<view class="from_city">{{item.start_distinct}}</view>
						<image class="direc" src="../../../static/images/cust_direc.png"></image>
						<view class="to_city">{{item.end_distinct}}</view>
					</view>
				</view>
			</view><!--block end-->
		</view><!--blocks end-->
	</view>
</template>

<script>
	import {index} from "@/api/index.js";
	import {travel_reco_list} from "@/api/travel.js";
	export default {
		data() {
			return {
				showSkeleton: true, //骨架屏显示隐藏
				indicatorDots: false,
				circular: true,
				autoplay: true,
				interval: 4000,
				duration: 500,
				carousels:[],//轮播
				data:[]//推荐路线
			}
		},
		onShareTimeline() {
			return {
				title: '出行拼车',
				//分享朋友圈的参数
				query: "isShare=1&id=",
			}
		},
		onShareAppMessage(){
		},
		onLoad() {
			this.getIndex();
			this.getData();
		},
		created() {
			
		},
		methods: {
			//轮播
			getIndex(){
				let that = this;
				index({}).then((res) => {
					let data = res.data;
					that.carousels = data.banners;
					that.ads = data.ads;
					that.driver = data.driver;
					if(data.driver < 100){
						that.driver = Math.floor(Math.random() * (100 - 50 + 1) ) + 50;
					}
				});
			},
			//推荐路线
			getData(){
				let that = this;
				travel_reco_list({}).then((res) => {
					let data = res.data.list;
					that.data = data;
				});
			},
			//查询行程
			queryTravel(){
				uni.navigateTo({
					url:'/pages/main/query/index'
				})
			},
			//发布行程
			publishTravel(){
				uni.navigateTo({
					url:'/pages/main/publish/index'
				})
			}
		}

	}
</script>

<style lang="scss" scope>
	view{
		background-color: white;
	}
	page{
		background-color: white;
	}
	.swiper{
		// mheight: 500rpx;
		padding: 0 0;
		.slide-image{
			width: 100%;
			height: 400rpx;
		}
	}
	
	.from_to_bg{
		background-color: white;
		margin-top: 20rpx;
		padding: 30rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		.left{
			display: flex;
			flex-direction: column;
			flex: 1;
			background-color: red;
			margin-right: 50rpx;
			.section{
				display: flex;
				flex-direction: row;
				align-items: center;
				.dot{
					width: 10rpx;
					height:10rpx;
					border-radius: 5rpx;
					background-color: red;
				}
				.city{
					margin-left: 30rpx;
					display: flex;
					flex-direction: row;
					flex: 1;
					padding: 20rpx 0rpx;
					.city_tip{
						font-size: 28rpx;
						font-weight: bold;
						color: black;
					}
					.city_text{
						margin-left: 50rpx;
						font-size: 28rpx;
						color: black;
					}
				}
				.line{
					border-bottom: 1rpx solid #f1f1f1;
				}
			}
		}
		.right{
			width: 50rpx;
			.change{
				width: 50rpx;
				height: 50rpx;
			}
		}
	}
	
	.func{
		background-color: white;
		margin-top: 20rpx;
		// padding: 30rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		.btn{
			font-size: 28rpx;
			color: white;
			margin-top: 10rpx;
			background-color: #dd783f;
			width: 48%;
			height: 80rpx;
			text-align: center;
			line-height: 80rpx;
		}
	}
	
	.blocks{
		display: flex;
		flex-direction: column;
		padding: 30rpx;
	
		.block{
			display: flex;
			flex-direction: column;
			margin-top: 10rpx;
			padding: 0rpx 0rpx;
				
			.top{
				height: 80rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				.top_title{
					font-weight: bold;
					color: black;
					font-size: 28rpx;
				}
				.top_more{
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					.more_text{
						color: gray;
						font-size: 28rpx;
					}
					.more_arrow{
						width: 26rpx;
						height:26rpx;
					}
				}
			}
			.empty{
				display: flex;
				flex-direction: column;
				justify-content:center;
				.empty_bg{
					display: flex;
					flex-direction: row;
					justify-content:center;
					margin-top: 100rpx;
					.empty_class{
						width:224rpx;
						height:146rpx;
					}
				}
				.desc_bg{
					text-align: center;
					font-size: 28rpx;
					color: black;
					margin-top: 40rpx;
					margin-bottom: 100rpx;
					.red{
						font-size: 42rpx;
						color: darkorange;
					}
				}
			}
			.items{
				display: flex;
				flex-direction: row;
				background-color: white;
				flex-wrap: wrap;
				justify-content: space-between;
				.item{
					display: flex;
					flex-direction: row;
					align-items: center;
					background-color: #f6f7fa;
					justify-content: space-between;
					width: 48%;
					height: 80rpx;
					margin-bottom: 30rpx;
					.from_city{
						flex: 1;
						color: black;
						font-size: 26rpx;
						background-color: transparent;
						text-align: center;
						white-space: nowrap;
						text-overflow:ellipsis;
						overflow:hidden;
						margin-left: 10rpx;
					}
					.direc{
						width: 50rpx;
						height:50rpx;
						margin-left: 15rpx;
						margin-right: 15rpx;
					}
					.to_city{
						flex: 1;
						color: black;
						font-size: 26rpx;
						background-color: transparent;
						text-align: center;
						white-space: nowrap;
						text-overflow:ellipsis;
						overflow:hidden;
						margin-right: 10rpx;
					}
				}
			}
		}
		
		
	}
	/** 须知弹窗 **/
	.popup-cls{
		display: flex;
		flex-direction: column;
		.pop-info{
			width:100%;
			display: flex;
			flex-direction: column;
			border-radius: 20rpx;
			margin: 0 auto;
			background-color: white;
			.pop-top{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				font-weight: bold;
				margin-top: 20rpx;
				text-align: center;
				padding-bottom: 30rpx;
				.cancel{
					font-size: 28rpx;
					color: dimgray;
					margin-left:30rpx;
					height: 60rpx;
					width: 130rpx;
					line-height: 60rpx;
				}
				.title{
					font-size: 30rpx;
					font-weight: bold;
				}
				.confirm{
					background-color: $uni-main-color;
					color: white;
					font-size: 28rpx;
					height: 60rpx;
					width: 130rpx;
					border-radius: 30rpx;
					line-height: 60rpx;
					margin-right:30rpx;
				}
			}
		}
		
		.center{
			width:100%;
			display: flex;
			flex-direction: column;
			.top_bg{
				background-color: oldlace;
				height: 80rpx;
				color: darkorange;
				font-size: 30rpx;
				line-height: 80rpx;
				padding-left: 30rpx;
			}
			.pop-content{
				padding: 0rpx 30rpx;
				display: flex;
				flex-direction: row;
				height: 500rpx;
				margin-top: 30rpx;
				.left{
					width: 280rpx;
					background-color: #f8f8f8;
					.section{
						padding-left: 30rpx;
						height: 80rpx;
						color: black;
						font-size: 28rpx;
						background-color: transparent;
						line-height: 80rpx;
					}
					.selected{
						background-color: white;
						color: darkorange;
						font-weight: bold;
					}
				}
				.right{
					margin-left: 30rpx;
					flex: 1;
					background-color: white;
					.section{
						height: 80rpx;
						color: black;
						font-size: 28rpx;
						line-height: 80rpx;
					}
					.selected{
						background-color: white;
						color: darkorange;
						font-weight: bold;
					}
				}
			}
		}
		
	}//popup-cls end
</style>
